This is the entire scene code from the scene titled, “Locked Room.” Following it is a breakdown of the code into sections, with explanations of each section.
PRINT{There is some cash in the cabinet! To count your money, enter a dollar sign.}
EXIT
PRINT{The left cupboard is empty.}
EXIT
IF{CLICK$=LEFT.OPEN}THEN
SOUND{DOOR CLOSING}
MOVE{LEFT.CLOSED}TO{SCENE@}
EXIT
IF{CLICK$=RIGHT.CLOSED}THEN
PRINT{.....................................}
SOUND{DOOR OPENING}
MOVE{RIGHT.CLOSED}TO{STORAGE@}
IF{POTION=STORAGE@}AND{PHYS.STR.BAS#<200}THEN
MOVE{POTION}TO{SCENE@}
PRINT{There is a strange liquid potion in the cabinet.}
EXIT
PRINT{The right cupboard is empty.}
EXIT
IF{CLICK$=RIGHT.OPEN}THEN
SOUND{DOOR CLOSING}
MOVE{RIGHT.CLOSED}TO{SCENE@}
EXIT
IF{CLICK$=LD.CLOSED}THEN
PRINT{.....................................}
IF{D1#<1}THEN
PRINT{This door is locked.}
EXIT
SOUND{DOOR OPENING}
MOVE{LD.CLOSED}TO{STORAGE@}
PRINT{The door SOUTH is now open.}
EXIT
IF{CLICK$=LD.OPEN}THEN
SOUND{DOOR CLOSING}
MOVE{LD.CLOSED}TO{SCENE@}
EXIT
IF{TEXT$=USE}THEN
PRINT{.....................................}
IF{TEXT$=KEY}THEN
IF{KEY>PLAYER@}THEN
PRINT{You don't have a key.}
EXIT
SOUND{PISTOL-COCKING.1}
IF{D1#<1}THEN
LET{D1#=1}
PRINT{The door is now unlocked and can be opened when you click on it.}
EXIT
MOVE{LD.CLOSED}TO{SCENE@}
LET{D1#=0}
PRINT{The door is now locked again.}
EXIT
IF{TEXT$=PISTOL}OR{TEXT$=GUN}THEN
IF{PISTOL=PLAYER@}THEN
PRINT{What do you want to shoot?}
EXIT
PRINT{You don't have a gun.}
EXIT
END
IF{TEXT$=SHOOT}THEN
PRINT{.....................................}
IF{PISTOL>PLAYER@}THEN
PRINT{You don't have a gun.}
EXIT
SOUND{GUNSHOT}
IF{TEXT$=DOOR}OR{TEXT$=LOCK}THEN
PRINT{The bullet just ricochets off the sturdy lock on the door.}
EXIT
IF{TEXT$=CABINET}THEN
PRINT{That might damaged whatever is inside. Besides, it's not even locked.}
EXIT
END
IF{TEXT$=GET}OR{TEXT$=TAKE}THEN
PRINT{.....................................}
IF{TEXT$=NOTE}THEN
PRINT{You can't get the note off the wall.}
EXIT
IF{TEXT$=LAMP}AND{LAMP.1=SCENE@}THEN
MOVE{LAMP.1}TO{STORAGE@}
MOVE{LAMP}TO{PLAYER@}
PRINT{You now have the lamp. There is still some fuel in it.}
IF{L1#=1}THEN
PRINT{The lamp is already lit, and gives off a steady glow.}
EXIT
PRINT{The lamp is not lit.}
EXIT
END
IF{TEXT$=READ}THEN
IF{TEXT$=NOTE}THEN
MOVE{NOTE.2}TO{SCENE@}
PRINT{.....................................}
PRINT{The note looks like someone's list of things to remember.}
EXIT
END
IF{CLICK$=NOTE.2}THEN
MOVE{NOTE.2}TO{STORAGE@}
EXIT
IF{CLICK$=NOTE.1}THEN
PRINT{.....................................}
END
IF{TEXT$=UNLOCK}THEN
PRINT{.....................................}
PRINT{What do you want to use to unlock the door?}
EXIT
IF{TEXT$=PICK}AND{TEXT$=LOCK}THEN
PRINT{.....................................}
PRINT{You don’t have anything suitable for the task.}
EXIT
**************End of code**************************
In this scene, there are two drawers that can be opened and closed, and two cupboard doors that can be opened and closed. There is also a door, which initially is locked. The player must find the key to open the door. On top of the cabinet there is a kerosene lamp that can be carried and lit, using matches. And on the wall there is a note. When the player reads the note, a closeup view is presented.
The first two statements in the scene code test for the words “open” and “close.” If the player enters the word “open,” text is printed telling the player to click on the thing he wants to open. If the player enters the word “close,” then he is told to click on the thing he wants to close:
IF{TEXT$=OPEN}THEN
PRINT{.....................................}
PRINT{Click on the thing you want to open.}
EXIT
IF{TEXT$=CLOSE}THEN
PRINT{.....................................}
PRINT{Click on the thing you want to close.}
EXIT
The statement below handles the player’s attempts to move south, the direction of the locked door. Object “LD.CLOSED” is a drawing of the closed door. It covers another object, LD.OPEN, that is invisible. If LD.CLOSED is in the scene, then the door is closed, and the inner statement is true. Text is then printed telling the player that the door is closed. This statement closes with EXIT, preventing the program from moving the player in that direction.
If LD.CLOSED is not in the scene, then the door is open, and the statement closes with END, allowing the player to be automatically moved to the next scene.
IF{TEXT$=SOUTH}THEN
IF{LD.CLOSED=SCENE@}THEN
PRINT{.....................................}
PRINT{The door is closed.}
EXIT
END
The drawers and doors each consist of two objects. The first is a drawing of the door or drawer in the closed position. These objects are in the scene at the beginning. In the case of the drawers, when the player clicks on the closed drawing (object), a sound is played and the object/drawing of the open drawer is moved to the scene, covering the “closed” object completely. The code below handles this action when the player clicks on the “closed” top drawer:
IF{CLICK$=TOP.CLOSED}THEN
PRINT{.....................................}
SOUND{SLIDE.1}
MOVE{TOP.OPEN}TO{SCENE@}
IF{MATCHES=STORAGE@}THEN
MOVE{MATCHES}TO{SCENE@}
PRINT{Inside the drawer you find some matches.}
EXIT
PRINT{The top drawer is empty.}
EXIT
>>>In the code above, the first statement tests to see if the player has clicked on the closed top drawer, an object called TOP.CLOSED. If so, the sound is played, and the drawing of the open drawer (TOP.OPEN) is moved to the scene. A nested statement check to see if the “matches” object is in storage. If so, then the matches are moved to the scene, and text is printed telling the player what he has found. If not, then the statement is ignored, and text is printed telling the player that the drawer is empty.<<<
The following code moves the TOP.OPEN object to storage and plays the appropriate sound when the player clicks on it. This creates the effect of closing the top drawer:
IF{CLICK$=TOP.OPEN}THEN
SOUND{SLIDE.1}
MOVE{TOP.OPEN}TO{STORAGE@}
EXIT
The next two sections of code are the same as the last two. They handle the opening and closing of the bottom drawer. When the player clicks on the drawing of the bottom drawer closed (BOTTOM.CLOSED) a sound is played and the “open” drawing/object is moved to the scene. A nested statement checks to see if the pistol is in storage, and if so, moves it to the scene. When the player clicks on the “open” drawer, it is moved to storage:
IF{CLICK$=BOTTOM.CLOSED}THEN
PRINT{.....................................}
SOUND{SLIDE.1}
MOVE{BOTTOM.OPEN}TO{SCENE@}
IF{PISTOL=STORAGE@}THEN
MOVE{PISTOL}TO{SCENE@}
PRINT{Inside the drawer you find a pistol.}
EXIT
PRINT{The bottom drawer is empty.}
EXIT
IF{CLICK$=BOTTOM.OPEN}THEN
SOUND{SLIDE.1}
MOVE{BOTTOM.OPEN}TO{STORAGE@}
EXIT
The code below handles opening and closing of the left and right cupboard doors. This is similar to the drawers, except that both the “open” and “closed” objects are in the scene at the beginning. When the “closed” object is clicked on, a “door opening” sound is played and the “closed” object is moved to storage. Then a nested statement checks to see if the objects the player is supposed to find are in storage. If so, those objects are moved to the scene.
When the player clicks on the “open” object, a “door closing” sound is played, and the “closed” object is moved to the scene.
When the player finds the cash, variable X1# is set to 7, giving the player seven dollars. This variable keeps track of the player’s money.
IF{CLICK$=LEFT.CLOSED}THEN
PRINT{.....................................}
SOUND{DOOR OPENING}
MOVE{LEFT.CLOSED}TO{STORAGE@}
IF{CASH=STORAGE@}THEN
MOVE{CASH}TO{SCENE@}
LET{X1#=7}
PRINT{There is some cash in the cabinet! To count your money, enter a dollar sign.}
EXIT
PRINT{The left cupboard is empty.}
EXIT
IF{CLICK$=LEFT.OPEN}THEN
SOUND{DOOR CLOSING}
MOVE{LEFT.CLOSED}TO{SCENE@}
EXIT
>>>When the player opens the right side cabinet door, a nested statement checks to see if the “potion” object is in storage, AND if the player’s current physical strength is less than 200. If BOTH of these is true, then the potion is moved to the scene.<<<
IF{CLICK$=RIGHT.CLOSED}THEN
PRINT{.....................................}
SOUND{DOOR OPENING}
MOVE{RIGHT.CLOSED}TO{STORAGE@}
IF{POTION=STORAGE@}AND{PHYS.STR.BAS#<200}THEN
MOVE{POTION}TO{SCENE@}
PRINT{There is a strange liquid potion in the cabinet.}
EXIT
PRINT{The right cupboard is empty.}
EXIT
IF{CLICK$=RIGHT.OPEN}THEN
SOUND{DOOR CLOSING}
MOVE{RIGHT.CLOSED}TO{SCENE@}
EXIT
The code below controls mouse clicks on the door to the south:
IF{CLICK$=LD.CLOSED}THEN
PRINT{.....................................}
IF{D1#<1}THEN
PRINT{This door is locked.}
EXIT
SOUND{DOOR OPENING}
MOVE{LD.CLOSED}TO{STORAGE@}
PRINT{The door SOUTH is now open.}
EXIT
The first statement above tests whether the player has clicked on the closed door, and object called LD.CLOSED. If so, then a nested statement checks the condition of variable D1#. If D1# is less than one, the statement is true, and text is printed telling the player that the door is locked. If it is not less than one, then the closed door object, LD.CLOSED, is moved to storage and the player is told that the door SOUTH is now open.
The statement below determines whether the player has clicked on LD.OPEN, an invisible, immobile object that covers the open doorway. If so, then a sound is played and the “closed” door object is moved to the scene:
IF{CLICK$=LD.OPEN}THEN
SOUND{DOOR CLOSING}
MOVE{LD.CLOSED}TO{SCENE@}
EXIT
To unlock the door, the player has to “use” the key. “Use” is the standard verb in these situations. The following code handles this:
IF{TEXT$=USE}THEN
PRINT{.....................................}
IF{TEXT$=KEY}THEN
IF{KEY>PLAYER@}THEN
PRINT{You don't have a key.}
EXIT
SOUND{PISTOL-COCKING.1}
IF{D1#<1}THEN
LET{D1#=1}
PRINT{The door is now unlocked and can be opened when you click on it.}
EXIT
MOVE{LD.CLOSED}TO{SCENE@}
LET{D1#=0}
PRINT{The door is now locked again.}
EXIT
IF{TEXT$=PISTOL}OR{TEXT$=GUN}THEN
IF{PISTOL=PLAYER@}THEN
PRINT{What do you want to shoot?}
EXIT
PRINT{You don't have a gun.}
EXIT
END
>>>In the code above, the first statement checks for entry of the verb “use.” If the player has entered “use”, then a nested statement checks for the word “key.” If the player has entered both “use” and “key” then another statement checks to see if the player actually has the key. If not, then the player is told that he doesn’t have the key.
If the player does have the key, then the previous statement is ignored, and a sound is played that simulates the sound of a key in a lock. Then a statement tests the value of the variable D1#. If D1# is less than one, then the door is locked. If the player uses the key and D1# is less than one, then D1# is set to one, and the player is told that he has just unlocked the door.
If D1# is already set to one when the player uses the key, then it is reset to 0, and the door is locked once more. For simplicity’s sake, the DOOR.CLOSED object is moved to the scene whenever the player locks the door, so that we don’t have to worry about whether it is open or closed when the player locks it.
If the player tries to “use” the pistol in this scene, a statement checks to see if the player actually has the pistol. If so, then the player is asked “What do you want to shoot?” This prompts the player to enter “shoot lock” if that is what he wants to do.<<<
It is reasonable to assume that some players may try to shoot the lock on the door, rather than finding the key to unlock it. So the code below deals with this action:
IF{TEXT$=SHOOT}THEN
PRINT{.....................................}
IF{PISTOL>PLAYER@}THEN
PRINT{You don't have a gun.}
EXIT
IF{TEXT$=DOOR}OR{TEXT$=LOCK}THEN
SOUND{GUNSHOT}
PRINT{The bullet just ricochets off the sturdy lock on the door.}
EXIT
IF{TEXT$=CABINET}THEN
PRINT{That might damaged whatever is inside. Besides, it's not even locked.}
EXIT
END
>>>In the code above, the first statement tests for entry of the word “shoot.” The first nested statement checks to see if the player has the pistol. If not, then text is printed telling the player that he doesn’t have a gun. If he does have the pistol, that statement is skipped.
The next nested statement tests to see if the player has entered the words “door” or “lock.” Both are treated the same. If either word has been entered, then a gunshot sound is played, and text is printed telling the player that the bullet has bounced off the lock without penetrating it.
If the player tries to shoot the cabinet, then the last nested statement tells the player that shooting the cabinet may damage the contents. Finally, the original “shoot” statement closes with END, so if the player tries to shoot any other objects, it will be handled by the default “shoot” statement in the Global code.<<<
The lamp on the cabinet can’t be picked up by clicking on it. The player has to enter “take lamp” or “get lamp.” Also, the player can’t take the note on the wall in this scene. The code below handles the verbs “get” and “take:”
IF{TEXT$=GET}OR{TEXT$=TAKE}THEN
PRINT{.....................................}
IF{TEXT$=NOTE}THEN
PRINT{You can't get the note off the wall.}
EXIT
IF{TEXT$=LAMP}AND{LAMP.1=SCENE@}THEN
MOVE{LAMP.1}TO{STORAGE@}
MOVE{LAMP}TO{PLAYER@}
PRINT{You now have the lamp. There is still some fuel in it.}
IF{L1#=1}THEN
PRINT{The lamp is already lit, and gives off a steady glow.}
EXIT
PRINT{The lamp is not lit.}
EXIT
END
>>>The first statement in the above code checks for entry of the words “get” or “take.” A nested statement then checks for use of the word “note.” If this statement is true, then text is printed telling the player that he can’t take the note.
The second nested statement checks for the word “lamp” and also checks to see if the immobile lamp object (LAMP.1) is in the scene. If both of these conditions is true, then LAMP.1 is moved to storage and the “lamp” mobile object is moved to the player. Another statement checks to see if the lamp has already been lit, and if so, tells the player that the lamp is lit. If not, that statement is passed over, and text is printed telling the player that the lamp is not lit.
Then the original “get/take” statement closes with END, so that any other objects can be picked up normally.<<<
The next bit of code handles the player’s request to read the note. The first statement checks for the word “read” and the inner statement checks for the word “note”. (Breaking the two words apart like this makes it possible for the player to enter the words in any form, including as part of a sentence. If the player enters “read the note on the wall,” the program picks up the two key words: “read” and “note.”) Then an object called NOTE.2 is moved to the scene. This object is a close up drawing of the note, allowing the player to see for himself what it contains:
IF{TEXT$=READ}THEN
IF{TEXT$=NOTE}THEN
MOVE{NOTE.2}TO{SCENE@}
PRINT{.....................................}
PRINT{The note looks like someone's list of things to remember.}
EXIT
END
The next statement moves the NOTE.2 object to storage when the player clicks on it:
IF{CLICK$=NOTE.2}THEN
MOVE{NOTE.2}TO{STORAGE@}
EXIT
All the other objects have special actions when they are clicked on in this scene, and the seperation line is printed as part of those actions. The object NOTE.1 doesn’t have any special actions, so the statement below prints the line of periods when it is clicked, before the object’s description is printed:
IF{CLICK$=NOTE.1}THEN
PRINT{.....................................}
END
This next code handles the verb “unlock.” Some players may try to use this verb to unlock the door, instead of entering “use key.” If so, this statement prints text which asks, “What do you want to use to unlock the door?” This prompts the player to enter the correct command in the required format:
IF{TEXT$=UNLOCK}THEN
PRINT{.....................................}
PRINT{What do you want to use to unlock the door?}
EXIT
A resourceful player will always try to pick a lock if the key is not at hand. The following code handles this:
IF{TEXT$=PICK}AND{TEXT$=LOCK}THEN
PRINT{.....................................}
PRINT{You don’t have anything suitable for the task.}